package com.itheima.leetcode.od.c.logicalsimulation;

import java.util.Scanner;

/**
 * <h3>分配土地</h3>
 */
public class AllocationOfLand {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int[] nums = new int[501];
        int[] max_row = new int[501];
        int[] max_col = new int[501];
        int[] min_row = new int[501];
        for (int i = 0; i < 501; i++) {
            min_row[i] = 502;
        }
        int[] min_col = new int[501];
        for (int i = 0; i < 501; i++) {
            min_col[i] = 502;
        }
        for (int i = 0; i < a; ++i) {
            for (int j = 0; j < b; ++j) {
                int c = in.nextInt();
                nums[c] = 1;
                max_row[c] = Math.max(max_row[c], i);
                max_col[c] = Math.max(max_col[c], j);
                min_row[c] = Math.min(min_row[c], i);
                min_col[c] = Math.min(min_col[c], j);
            }

        }
        int max_area = 0;
        for (int i = 1; i < 501; i++) {
            int c = nums[i];
            if (nums[i] == 1) {
                max_area = Math.max(max_area, (max_row[i] - min_row[i] + 1) * (max_col[i] - min_col[i] + 1));
            }
        }
        System.out.println(max_area);
    }
}